﻿using System;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace APMAWebConsole.Account
{
    public partial class Register : Page
    {

        protected void Page_Load(object sender, EventArgs e)
        {
            //RegisterUser.ContinueDestinationPageUrl = Request.QueryString["ReturnUrl"];
        }

        protected void CreateUserButton_OnCommand(object sender, CommandEventArgs e)
        {
            switch (e.CommandName)
            {
                case "Register":
                    {
                        if (CreateNewUser(UserName.Text, Password.Text, Email.Text))
                        {
                            FormsAuthentication.SetAuthCookie(UserName.Text, false);
                            Response.Redirect("~/");
                        }
                        else
                        {
                            ErrorMessage.Text = "Can not create user.";
                        }

                        break;
                    }
            }
        }

        private bool CreateNewUser(string login, string password, string email)
        {
            //return SiteMaster.Proxy.CreateUser(login, password, email);
            return true;
        }

    }
}
